package cn.sxgan.gen.utils;

import cn.sxgan.gen.model.GlobalDataSource;

/**
 * @Description: 公共工具类
 * @Author: sxgan
 * @Date: 2025-07-23 16:24
 * @Version: 1.0
 **/

public class CommonUtils {
    
    /**
     * 获取数据库链接地址
     *
     * @param globalDataSource
     * @return
     */
    public static String getDbUrl(GlobalDataSource globalDataSource) {
        return String.format(
                "jdbc:%s://%s:%s/%s?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai",
                globalDataSource.getDbType(),
                globalDataSource.getHost(),
                globalDataSource.getPort(),
                globalDataSource.getDbName()
        );
    }
}
